#include <iostream>
using namespace std;
#define maxsize 100000
int main()
{
	int n,a[maxsize],b[maxsize],i,j,max=-1;
	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >>a[i];
		b[i]=1;
	}
	
	for(i=0,j=0;i<n-1;i++)
	{
		if(a[i]<a[i+1])
		b[j]++;
		else
		j=i+1;
	}
	for(i=0;i<n;i++)
	if(max<b[i])
	{
		max=b[i];
		j=i;
	}
	for(i=j;i<j+max-1;i++)
	{
		cout << a[i];
		cout << " ";
	}
	cout << a[i];
	return 0;
}
